/**
 * Created with IntelliJ IDEA.
 * Description:
 */
public class MyCircularQueue {
    public int[] array;
    public int front;
    public int rear;
    public int size;
    public MyCircularQueue(int k) {
        array=new int[k];
    }

    public boolean enQueue(int value) {
        if(isFull()){
            return false;
        }
        array[rear]=value;
        rear=(rear+1)%array.length;
        size++;
        return true;
    }

    public boolean deQueue() {
        if(isEmpty()){
            return false;
        }
        front=(front+1)%array.length;
        size--;
        return true;
    }

    public int Front() {
        if(isEmpty()){
            return -1;
        }
        return array [front];
    }

    public int Rear() {
        if(isEmpty()){
            return -1;
        }
        return array[(rear-1+array.length)%array.length];
    }

    public boolean isEmpty() {
        return size==0;
    }

    public boolean isFull() {
        return size==array.length;
    }
}
